/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package eu.fsiebert.polytech.db.mediatheque.entity;

import java.io.Serializable;
import java.util.Date;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.Lob;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.persistence.UniqueConstraint;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;

/**
 *
 * @author Florent
 */
@Entity
@Table(name = "Adherent", uniqueConstraints = {
    @UniqueConstraint(columnNames = {"Login", "Password"}),
    @UniqueConstraint(columnNames = {"NomAdherent", "PrenomAdherent", "DateNaissance"})})
@NamedQueries({
    @NamedQuery(name = "Adherent.findAll", query = "SELECT a FROM Adherent a"),
    @NamedQuery(name = "Adherent.findByNoCarte", query = "SELECT a FROM Adherent a WHERE a.noCarte = :noCarte"),
    @NamedQuery(name = "Adherent.findByNomAdherent", query = "SELECT a FROM Adherent a WHERE a.nomAdherent = :nomAdherent"),
    @NamedQuery(name = "Adherent.findByPrenomAdherent", query = "SELECT a FROM Adherent a WHERE a.prenomAdherent = :prenomAdherent"),
    @NamedQuery(name = "Adherent.findByDateNaissance", query = "SELECT a FROM Adherent a WHERE a.dateNaissance = :dateNaissance"),
    @NamedQuery(name = "Adherent.findByDateAdhesion", query = "SELECT a FROM Adherent a WHERE a.dateAdhesion = :dateAdhesion"),
    @NamedQuery(name = "Adherent.findByLogin", query = "SELECT a FROM Adherent a WHERE a.login = :login"),
    @NamedQuery(name = "Adherent.findByPassword", query = "SELECT a FROM Adherent a WHERE a.password = :password")})
public class Adherent implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @NotNull
    @Column(name = "NoCarte", nullable = false)
    private Integer noCarte;
    @Basic(optional = false)
    @NotNull
    @Lob
    @Size(min = 1, max = 65535)
    @Column(name = "Adresse", nullable = false, length = 65535)
    private String adresse;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 50)
    @Column(name = "NomAdherent", nullable = false, length = 50)
    private String nomAdherent;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 50)
    @Column(name = "PrenomAdherent", nullable = false, length = 50)
    private String prenomAdherent;
    @Basic(optional = false)
    @NotNull
    @Column(name = "DateNaissance", nullable = false)
    @Temporal(TemporalType.DATE)
    private Date dateNaissance;
    @Basic(optional = false)
    @NotNull
    @Column(name = "DateAdhesion", nullable = false)
    @Temporal(TemporalType.TIMESTAMP)
    private Date dateAdhesion;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 100)
    @Column(name = "Login", nullable = false, length = 100)
    private String login;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 40)
    @Column(name = "Password", nullable = false, length = 20)
    private String password;
    @JoinColumn(name = "LieuResidence", referencedColumnName = "idLieuResidence", nullable = false)
    @ManyToOne(optional = false)
    private LieuResidence lieuResidence;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "noCarte")
    private List<Suggestion> suggestionList;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "noCarte")
    private List<Emprunt> empruntList;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "noCarte")
    private List<CommandeDuJour> commandeDuJourList;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "noCarte")
    private List<Reservation> reservationList;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "adherent")
    private List<AdherentSoldeCompte> adherentSoldeCompteList;

    public Adherent() {
    }

    public Adherent(Integer noCarte) {
        this.noCarte = noCarte;
    }

    public Adherent(Integer noCarte, String adresse, String nomAdherent, String prenomAdherent, Date dateNaissance, Date dateAdhesion, String login, String password) {
        this.noCarte = noCarte;
        this.adresse = adresse;
        this.nomAdherent = nomAdherent;
        this.prenomAdherent = prenomAdherent;
        this.dateNaissance = dateNaissance;
        this.dateAdhesion = dateAdhesion;
        this.login = login;
        this.password = password;
    }

    public Integer getNoCarte() {
        return noCarte;
    }

    public void setNoCarte(Integer noCarte) {
        this.noCarte = noCarte;
    }

    public String getAdresse() {
        return adresse;
    }

    public void setAdresse(String adresse) {
        this.adresse = adresse;
    }

    public String getNomAdherent() {
        return nomAdherent;
    }

    public void setNomAdherent(String nomAdherent) {
        this.nomAdherent = nomAdherent;
    }

    public String getPrenomAdherent() {
        return prenomAdherent;
    }

    public void setPrenomAdherent(String prenomAdherent) {
        this.prenomAdherent = prenomAdherent;
    }

    public Date getDateNaissance() {
        return dateNaissance;
    }

    public void setDateNaissance(Date dateNaissance) {
        this.dateNaissance = dateNaissance;
    }

    public Date getDateAdhesion() {
        return dateAdhesion;
    }

    public void setDateAdhesion(Date dateAdhesion) {
        this.dateAdhesion = dateAdhesion;
    }

    public String getLogin() {
        return login;
    }

    public void setLogin(String login) {
        this.login = login;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public LieuResidence getLieuResidence() {
        return lieuResidence;
    }

    public void setLieuResidence(LieuResidence lieuResidence) {
        this.lieuResidence = lieuResidence;
    }

    public List<Suggestion> getSuggestionList() {
        return suggestionList;
    }

    public void setSuggestionList(List<Suggestion> suggestionList) {
        this.suggestionList = suggestionList;
    }

    public List<Emprunt> getEmpruntList() {
        return empruntList;
    }

    public void setEmpruntList(List<Emprunt> empruntList) {
        this.empruntList = empruntList;
    }

    public List<CommandeDuJour> getCommandeDuJourList() {
        return commandeDuJourList;
    }

    public void setCommandeDuJourList(List<CommandeDuJour> commandeDuJourList) {
        this.commandeDuJourList = commandeDuJourList;
    }

    public List<Reservation> getReservationList() {
        return reservationList;
    }

    public void setReservationList(List<Reservation> reservationList) {
        this.reservationList = reservationList;
    }

    public List<AdherentSoldeCompte> getAdherentSoldeCompteList() {
        return adherentSoldeCompteList;
    }

    public void setAdherentSoldeCompteList(List<AdherentSoldeCompte> adherentSoldeCompteList) {
        this.adherentSoldeCompteList = adherentSoldeCompteList;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (noCarte != null ? noCarte.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Adherent)) {
            return false;
        }
        Adherent other = (Adherent) object;
        if ((this.noCarte == null && other.noCarte != null) || (this.noCarte != null && !this.noCarte.equals(other.noCarte))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "eu.fsiebert.polytech.db.mediatheque.entity.Adherent[ noCarte=" + noCarte + " ]";
    }
    
}
